/*****************************************************************************
 *   Copyright 2005 Tim A Wang
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 ****************************************************************************/
package com.jb.web.application;

import com.jb.framework.PersistentContext;

import com.jb.framework.util.PropUtil;

import com.jb.web.model.GUID;

import com.jb.faces.component.UIComponentBase;


public abstract class WebBeanz extends UIComponentBase {
    protected long changeToken = 0;

    // private transient ArrayList vetoableChangeListeners = new ArrayList(2);

    /**
     * Creates a new Beanz object.
     *
     * @param newName Parameter
     */
    public WebBeanz(String newName) {
        setId(newName);
        init();
    }

    /**
     * Creates a new Beanz object.
     */
    public WebBeanz() {
        setId(GUID.next(getClass()));
        init();
    }

    public String getFamily() {
        return getClass().getName();
    }

    public boolean setPropertyValue(String propName, Object propValue) {
        return PropUtil.setProperty(this, propName, propValue);
    }

    public boolean equals(WebBeanz object) {
        return (changeToken == object.changeToken) && getId().equals(object.getId()) &&
        (getClass() == object.getClass());
    }
     
    public boolean valueChanged(PersistentContext pCtx) {
        return true;
    }

    protected void init() {
    }
}
